/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.actions.delete;

import org.eclipse.gef.ui.actions.WorkbenchPartAction;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;

import com.cea.papyrus.core.editor.DiagramEditorPage;
import com.cea.papyrus.core.editor.ModelManager;
import com.cea.papyrus.core.editor.MultiDiagramEditor;


/**
 * 
 */
public class DeleteDiagramAction
	extends WorkbenchPartAction
{

	/**
	 * 
	 */
	public static String DELETE_DIAGRAM = "DeleteDiagram";
	
	/**
	 * 
	 */
	public static String ACTION_Label = "Delete Diagram";
	
	/**
	 * 
	 */
	public static String ACTION_Tooltip = "Delete Selected Diagram";


/**
 * 
 * 
 * @param part 
 */
public DeleteDiagramAction(IWorkbenchPart part) {
	super(part);
		setText(ACTION_Label);
		setId(DELETE_DIAGRAM);
		setToolTipText(ACTION_Tooltip);
		ISharedImages sharedImages = PlatformUI.getWorkbench().getSharedImages();
		setImageDescriptor( sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
		setDisabledImageDescriptor(sharedImages
						.getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD_DISABLED));


		setHoverImageDescriptor(sharedImages.getImageDescriptor(ISharedImages.IMG_TOOL_NEW_WIZARD));
}

/**
 * 
 * 
 * @return 
 */
@Override
protected boolean calculateEnabled() {
	return true;
}

/**
 * 
 */
@Override
public void run() {
	MultiDiagramEditor editor = ((MultiDiagramEditor) getWorkbenchPart());
	ModelManager mngr = editor.getModelManager();
	mngr.removeDiagram( ((DiagramEditorPage) editor.getActiveEditor()).getDiagramModel());
}

}

